package pattern10.eventcommission;

/**
 * 通过事件委托实现观察者模式
 *
 * @author wdl
 */
public class ObserverPatternByEventCommission {
    public static void main(String[] args) {
        //前台秘书
        Secretary secretary = new Secretary();

        //看股票的同事
        StockObserver stockObserver = new StockObserver("同事1", secretary);
        //看NBA的同事
        NBAObserver nbaObserver = new NBAObserver("同事2", secretary);

        secretary.addListener(stockObserver, "closeStockMarket");
        secretary.addListener(nbaObserver, "closeNBA");

        secretary.setSubjectState("老板来了");

        secretary.notifyX();
    }
}
